import 'dart:typed_data';

import '../../response/response_data_base.dart';

class HuariResponseData extends ResponseDataBase {
  // 响应数据
  // 第一个字节是响应码，后续字节是实际数据
  final Uint8List _rsp;

  HuariResponseData({required Uint8List rsp}) : _rsp = rsp;

  @override
  Uint8List get data {
    if (_rsp.length > 1) {
      return Uint8List.fromList(_rsp.sublist(1));
    }
    return Uint8List(0);
  }

  @override
  int get code => _rsp.isNotEmpty ? _rsp.first : 0x00;

  @override
  bool get isSuccess => code == 0x01;
}
